package modelo.tabla;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Marlon
 */
public class ModeloTablaDatos extends AbstractTableModel {

    private String[] columnNames;
    private List<Double> data;

    public ModeloTablaDatos(String[] columnNames, List<Double> data) {
        this.columnNames = columnNames;
        this.data = data;
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return true;
    }

    @Override
    public Class getColumnClass(int columnIndex) {
        return Double.class;
    }

    @Override
    public int getRowCount() {
        return 1;
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return data.get(columnIndex);
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        data.set(columnIndex, (Double) aValue);
        fireTableDataChanged();
    }

    public String[] getColumnNames() {
        return columnNames;
    }

    public List<Double> getData() {
        return data;
    }
}
